package com.study.common;

import java.util.Stack;

public class StackTest {
    static Stack stack1 = new Stack();

    static Stack stack2 = new Stack();


    public static void main(String[] args) {
        System.out.println("入队顺序");
        for (int i = 0; i <10 ; i++) {
            System.out.println(i);
            StackTest.add(i);
        }

        System.out.println("出队列顺序");
        for (int i = 0; i <10 ; i++) {
            System.out.println(StackTest.get());
        }
    }


    static void add(Object o) {

        stack1.push(o);

    }

    static Object get() {

    if (stack2.isEmpty()){
        while (!stack1.isEmpty()) {
            stack2.push(stack1.pop());
        }
    }


        return stack2.pop();
    }
}
